Micron Document




Project Valhalla (Java language)
part 2/6 · 8.3 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Planned features

Valhalla is incubating Java language features and enhancements in these areas:cite-ref-3[3]cite-ref-4[4]

Value Classes and Objects: highly-efficient objects without their own identity (reference value).
• Null-restricted and Nullable types, and Null-restricted Objects: for example, using ? or ! after type declaration to say if null is allowed or not.
• Enhanced Primitive Boxing: for example, to allow code such as List<int>.
Reified Generics: retaining actual type at runtime.

These features will require both syntax and VM-level changes.

Project components

The project is organized into several JEPs (JDK Enhancement Proposals):

• JEP draft: Value Objects (Withdrawn)cite-ref-5[5]
• JEP 401: Primitive Classes (Preview)cite-ref-6[6]
• JEP 402: Enhanced Primitive Boxing (Preview)cite-ref-7[7]
• JEP draft: Universal Generics (Withdrawn)cite-ref-8[8]
• JEP draft: Null-Restricted Value Class Types (Preview)cite-ref-9[9]

Value classes

Value classes are reference types, in the same way as all existing Java classes. However, they give up the ability to have identity. This means that the == operator compares instance of the value class by equality of their components, instead of by identity. Additionally, synchronizing on instances of value classes will fail.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────